import React from 'react';
/**
 * 业务类型列表
 * @method businessTypeList
 * created by wjxu on 2018-05-25T16:29:47+0800
 * modify by wjxu on 2018-05-25T16:29:47+0800
 * @param  {Boolean}        options.hasAll      是否显示全部
 * @return {Array}                              [description]
 */
export function businessTypeList({ hasAll = true, hasError, hasRunning, hasFinished }) {
  const list = [];
  if (hasAll) {
    list.push({
      text: '全部',
      value: '',
    });
  }
  if (hasError) {
    list.push({
      text: '异常批次',
      value: 'error',
    });
  }
  if (hasRunning) {
    list.push({
      text: '运行批次',
      value: 'running',
    });
  }
  if (hasFinished) {
    list.push({
      text: '完成批次',
      value: 'finished',
    });
  }
  return list;
}

export const timeTypeList = [{
  text: '12小时',
  value: '12h',
}, {
  text: '24小时',
  value: '24h',
}, {
  text: '48小时',
  value: '48h',
}, {
  text: '7天',
  value: '7d',
}];

export function batchTableCols(needOper = true) {
  const cols = [{
    dataField: 'batchId',
    name: '批次号',
    isKey: true,
  }, {
    dataField: 'businessType',
    name: '业务分类',
  }, {
    dataField: 'exeStartTime',
    name: '执行开始时间',
  }, {
    dataField: 'exeEndTime',
    name: '执行结束时间',
  }, {
    dataField: 'exeResult',
    name: '执行结果信息',
  }];
  if (needOper) {
    cols.push({
      dataField: 'oper',
      name: '操作',
      dataFormat() {
        return (<a href="./">导出</a>);
      },
    });
  }
  return cols;
}
